<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Symbol</title>
	</head>
	<body>
		<script type="text/javascript">
			//Symbol  ES6新增的原始数据，表示独一无二的值，由symbol函数创建
			let sym1 = Symbol();
			let sym2 = Symbol();
			console.log(sym1); //Symbol()
			console.log(sym1 == sym2);   //false
			
			let sym3 = Symbol("username");
			let sym4 = Symbol("password");
			let obj = {
				"username":"刘冬",
				"age":21
			}
			obj.username = "枫叶在飘呀"
			console.log(obj);
			let obj2 = {
				[sym3]:"小刘",
				[sym4]:"1234567"
			}
			obj2[sym3] = "枫叶在飘"
			console.log(obj2) //{Symbol(username): "枫叶在飘", Symbol(password): "1234567"}
			function fun()
			{
				let sym5 = Symbol("username");
				let sym6 = Symbol("password");
				return {
					[sym5]:"刘冬",
					[sym6]:34
				}
			}
		console.log(fun());//{Symbol(username): "刘冬", Symbol(password): 34}
		</script>
	</body>
</html>
